<?php 
if($_REQUEST['site'] > 0)
{ $themes = getSiteThemes($_REQUEST['site']); }
$hfbsets = getHFBSetList();
$types = getThemeTypes();
if(!$sites)
{ $sites  = getSitesList(); }
require('components/common/toolbox.php'); 
?>
<div class="menu_top">
	<input type="hidden" id="action" name="action" value="lista">
	<input type="submit" value="Add new theme" class="buttons" style="padding-left:20px; padding-right:10px;  background-image: url('../images/system/new.gif'); border:1px solid #DDDDDD;" />&nbsp;&nbsp;
	Title:&nbsp;&nbsp;<input name="new_title" type="text" value="" maxlength="99" size="12">&nbsp;&nbsp;&nbsp;&nbsp;
	<input type="submit" value="Save" style="padding-left:20px; padding-right:10px;  background-image: url('../images/system/save.gif'); border:1px solid #DDDDDD; height:20px;" class="buttons">
</div>
<div class="menu_list">
<table id="menulist" class="item_list" cellspacing="0" cellpadding="0" border="0">
	<tr>
		<th nowrap="nowrap">#&nbsp;ID&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Title&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Type&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Com HFB Set&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Mod HFB Set&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Copy To Site&nbsp;&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Default&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Edit&nbsp;&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Delete&nbsp;&nbsp;&nbsp;</th>
	</tr>
	<?php 
	if($themes):
	foreach($themes as $theme)
	{
	?>
	<tr class="items">
		<td nowrap="nowrap">
			<input type="hidden" name="theme_id[]" value="<?php echo $theme['id']; ?>" />
			<input size="3" style="width:30px;" class="inp_txt" name="theme_id_txt[]" type="text" value="<?php echo $theme['id']; ?>" maxlength="90" />
		</td>
		<td nowrap="nowrap"><input style="width:80px;" class="inp_txt" name="title[]" type="text" value="<?php echo $theme['title']; ?>" maxlength="90" /></td>
		<td nowrap="nowrap">
			<select name="theme_type[]" style="width:110px;" onChange="submit();" >
				<option value="0">None</option>
				<?php 
				if($types)
				{
					foreach($types as $type)
					{
						
						if ($type['id'] == $theme['theme_type'])
						{
							echo '<option value="'.$type['id'].'" selected="selected">'.$type['title'].'</option>';
						}
						else
						{
							echo '<option value="'.$type['id'].'">'.$type['title'].'</option>';
						}
					}
				}
				?>
			</select>
		</td>
		<td nowrap="nowrap">
			<select name="hfb_com_set[]" style="width:100px;" onChange="submit();" >
				<option value="0">None</option>
				<?php 
				if($hfbsets)
				{
					foreach($hfbsets as $hfbset)
					{
						if ($hfbset['id'] == $theme['hfb_com_set'])
						{
							echo '<option value="'.$hfbset['id'].'" selected="selected">'.$hfbset['name'].'</option>';
						}
						else
						{
							echo '<option value="'.$hfbset['id'].'">'.$hfbset['name'].'</option>';
						}
					}
				}
				?>
			</select>
		</td>
		<td nowrap="nowrap">
			<select name="hfb_set[]" style="width:100px;" onChange="submit();" >
				<option value="0">None</option>
				<?php 
				if($hfbsets)
				{
					foreach($hfbsets as $hfbset)
					{
						if ($hfbset['id'] == $theme['hfb_set'])
						{
							echo '<option value="'.$hfbset['id'].'" selected="selected">'.$hfbset['name'].'</option>';
						}
						else
						{
							echo '<option value="'.$hfbset['id'].'">'.$hfbset['name'].'</option>';
						}
					}
				}
				?>
			</select>
		</td>
		<td nowrap="nowrap">
			<select name="copy_to[]" style="width:110px;" onChange="submit();" >
				<option value="0">None</option>
				<?php 
				if($sites)
				{
					foreach($sites as $site)
					{
						echo '<option value="'.$site['id'].'">'.$site['title'].'</option>';
					}
				}
				?>
			</select>
		</td>
		<td nowrap="nowrap">
			<?php if($theme['site_default'] == 0): ?>
			<img src="../images/system/default_<?php echo $theme['site_default']; ?>_25.gif" alt="default" onmousedown="document.getElementById('default').value='<?php echo $theme['id']; ?>';" onmouseup="edit_form.submit();" />
			<?php else: ?>
			<img src="../images/system/default_<?php echo $theme['site_default']; ?>_25.gif" alt="dedefault" onmousedown="document.getElementById('dedefault').value='<?php echo $theme['id']; ?>';" onmouseup="edit_form.submit();" />
			<?php endif; ?>
		</td>
		<td nowrap="nowrap">
			<a href="?con=<?php echo $_REQUEST['con']; ?>&item=<?php echo $theme['id']; ?>"><img src="../images/system/templ.gif" border="0" /></a>&nbsp;
		</td>
		<td nowrap="nowrap"><input class="inp_image" type="image" name="delete_theme" src="../images/system/trash_25.gif" value="0" onclick="this.value='<?php echo $theme['id']; ?>'; edit_form.submit();" /></td>
	</tr>
	<?php
	}
	?>
    <?php endif; ?>
</table>
<input type="hidden" id="dedefault" name="dedefault" value="0" />
<input type="hidden" id="default" name="default" value="0" />
</div>
